#include "Fence.h"
#include "ResourceManager.h"
#include <d3dx9.h>

Fence::Fence(int id,float x, float y, int type)
{
	switch(type)
	{
	case 19:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Bush),0, 0);
		break;
	case 20: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Cloud),300, 0);
		break;
	case 21:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Left),0, 0);
		break;
	case 22: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Middle),0, 0);
		break;
	case 23:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Right),0, 0);
		break;
	case 24: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Bottom),0, 0);
		break;
	case 25:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Middle),0, 0);
		break;
	case 26: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Top),0, 0);
		break;
	case 27:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Small),0, 0);
		break;
	case 28: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Trunk),0, 0);
		break;
	case 35:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Left),0, 0);
		break;
	case 36:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Middle),0, 0);
		break;
	case 37: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Right),0, 0);
		break;
	case 45:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Left_2),0, 0);
		break;
	case 46: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Middle_2),0, 0);
		break;
	case 47:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Ground_Right_2),0, 0);
		break;
	case 57: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Left_3),0, 0);
		break;
	case 58:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Middle_3),0, 0);
		break;
	case 59: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Fence_Right_3),0, 0);
		break;
	case 71:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Bottom_3),0, 0);
		break;
	case 72: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Middle_3),0, 0);
		break;
	case 73:
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Small_3),0, 0);
		break;
	case 74: 
		_sprite = new Sprite(_spriteHandler, ResourceManager::GetInstance()->GetTexture(ResourceManager::GetInstance()->TextureName.Tree_Top_3),0, 0);
		break;
	}
	_id = id;
	_x = x;
	_y = y;
	_width = _sprite->getTexture()->getWidth();
	_height = _sprite->getTexture()->getHeight();
	
}

Fence::~Fence(void)
{
	if (_sprite)
	{
		delete _sprite;
	}
	
}

void Fence::Update(list<Object *> *_list, float time)
{
	_sprite->Update(time);
}


void Fence:: Render(int vpX, int vpY)
{
	_sprite->Render(_x, _y, vpX, vpY);
}

OBJECT_TYPE Fence::getObjectType()
{
	return OBJECT_STATIC;
}